package com.wu.store.controller;

import com.wu.store.annotation.AdminUser;
import com.wu.store.common.util.MessageEntity;
import com.wu.store.dao.BrandDao;
import com.wu.store.entity.Brand;
import com.wu.store.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/brand")
public class BrandController {
	@Autowired
	private BrandService brandService;

	@Autowired
	private BrandDao brandDao;

	@RequestMapping("/list")
	public MessageEntity list(String keyword) {
		return new MessageEntity.Builder().success(true).message("获取成功").data(brandService.list(keyword)).create();
	}

	@RequestMapping("/save")
	public MessageEntity save(@AdminUser boolean isAdmin, Brand brand) throws Exception{
		return new MessageEntity.Builder().success(true).message("操作成功").data(brandService.save(brand)).create();
	}

	@RequestMapping("/delete")
	public MessageEntity delete(@AdminUser boolean isAdmin, Long id){
		return new MessageEntity.Builder().success(true).message("操作成功").data(brandDao.delete(id)).create();
	}
}
